﻿using System.Data.Linq;
using System.Data.Linq.Mapping;

namespace WeiboPlus.Models
{
    [Table(Name = "sns_friendship")]
    public class SNSFriendship : NotificationObject
    {
        [Column(Name = "source_id", IsPrimaryKey = true)]
        long _sourceId;
        EntityRef<SNSFriendshipItem> _source;
        [Association(Name = "fk_friendship_source", ThisKey = "_sourceId", OtherKey = "ID")]
        public SNSFriendshipItem Source
        {
            get
            {
                return _source.Entity;
            }
            set
            {
                RaisePropertyChanging("Source");
                _source.Entity = value;
                if (value != null)
                {
                    _sourceId = value.ID;
                }
                RaisePropertyChanged("Source");
            }
        }

        [Column(Name = "target_id", IsPrimaryKey = true)]
        long _targetId;
        EntityRef<SNSFriendshipItem> _target;
        [Association(Name = "fk_friendship_target", ThisKey = "_targetId", OtherKey = "ID")]
        public SNSFriendshipItem Target
        {
            get
            {
                return _target.Entity;
            }
            set
            {
                RaisePropertyChanging("Target");
                _target.Entity = value;
                if (value != null)
                {
                    _targetId = value.ID;
                }
                RaisePropertyChanged("Target");
            }
        }
    }

    [Table(Name = "sns_friendship_item")]
    public class SNSFriendshipItem : NotificationObject
    {
        long _id;
        [Column(Name = "id")]
        public long ID
        {
            get
            {
                return _id;
            }
            set
            {
                RaisePropertyChanging("ID");
                _id = value;
                RaisePropertyChanged("ID");
            }
        }

        string _screenName;
        [Column(Name = "screen_name")]
        public string ScreenName
        {
            get
            {
                return _screenName;
            }
            set
            {
                RaisePropertyChanging("ScreenName");
                _screenName = value;
                RaisePropertyChanged("ScreenName");
            }
        }

        bool _following;
        [Column(Name = "is_following")]
        public bool Following
        {
            get
            {
                return _following;
            }
            set
            {
                RaisePropertyChanging("Following");
                _following = value;
                RaisePropertyChanged("Following");
            }
        }

        bool _followBy;
        [Column(Name = "is_follow_by")]
        public bool FollowBy
        {
            get
            {
                return _followBy;
            }
            set
            {
                RaisePropertyChanging("FollowBy");
                _followBy = value;
                RaisePropertyChanged("FollowBy");
            }
        }
    }
}
